package com.fr.lintcode;

import org.junit.Test;

public class Q100 {
    public int removeDuplicates(int[] nums) {
        if (nums == null || nums.length == 0) {
            return 0;
        }
        int k = nums[0];
        int index = 1;
        for (int i = 1; i < nums.length; i++) {
            if (k != nums[i]) {
                k = nums[i];
                nums[index] = k;
                index++;
            }
        }
        return index;

    }

    @Test
    public void testA() {
        int[] nums = { 1, 1, 2 };
        System.out.println(removeDuplicates(nums));

    }

}
